<?
ob_start();
include '/var/www/html/new/d/common/header.html';
include '/var/www/html/new/d/common/left.html';
include '/var/www/html/new/d/common/autoload.php';
include '/var/www/html/new/d/common/Prod_Common.php';
$out_html=ob_get_contents();
ob_end_clean();


if(!($sid = $_SESSION['sid'])) exit('{"status":"failure","msg":"登录超时"}');
$prods = array();


// 身份验证
if(!in_array($_SESSION['sdtype'], array(0,2,6,9)) && !isset($_REQUEST['action'])) exit('身份不合法');

if($_SESSION['sdtype']==2){// 直接资源方
	$sql = "select apply_did from uu_land where salerid=".$_SESSION['saccount']." limit 1";
	$GLOBALS['le']->query($sql);
	if(!$GLOBALS['le']->fetch_assoc()) exit('{"status":"failure","msg":"身份不合法"}');
	$sid = $s_sid = $GLOBALS['le']->f('apply_did');
}
		
		
// 获取产品
$fuzzy = '';
if($sid!=1) $where1 = "apply_did=$sid and ";
if(($_GET['sid']+0)>0) $where1 = "id={$_GET['sid']} and ";
if($s_sid) $where1.= "salerid='".$_SESSION['saccount']."' and ";
if(isset($_REQUEST['keyword'])) $fuzzy = "and title like '%".trim($_REQUEST['keyword'])."%'";
$sql = "select title,salerid,terminal,imgpath,id,p_type from uu_land where $where1 status<3 and p_type<>'F' $fuzzy order by p_type asc";
// echo $sql;
$GLOBALS['le']->query($sql);
$prods = array();
while($r = $GLOBALS['le']->fetch_assoc()) $prods[] = $r;

// 异步获取搜索产品
if(isset($_REQUEST['action']) && $_REQUEST['action']=='queryproduct'){
	if(!in_array($_SESSION['sdtype'], array(0,2,6,9))) 
		exit('{"status":"failure","msg":"身份不合法"}');
	exit(json_encode(array('status'=>'success','list'=>$prods)));
	exit;
}

$var['prods'] = $prods;// 产品信息

echo $out_html;
include '/var/www/html/new/d/module/wxh/terminal/terminal.html';
include '/var/www/html/new/d/common/footer.html';
?>